<!-- 产品管理 -->
<script lang="ts">
export default {
    name: "xjyxproductManagement",
};
</script>
<template>
    <div class="page-box h100 display-flex czbj">
        <p class="title-label mb10" v-if="pup!=2">
            产品管理
        </p>
        <div>
            <dxtable :hidebj="hidebj" :headBtn='headBtn' :dataJson="dataJson" :portUrl="portUrl" :qx="qx" ref="databale"
                sonRouter="xjyxadditiveProduct"></dxtable>
        </div>   
    </div>
</template>
<script lang='ts' setup>
import { rowDark } from "naive-ui/es/legacy-grid/styles";
import dxtable from "../../components/util/dxtable.vue";
import sort from "../../components/util/sort.vue";
import { dxget, dxpost, qurl, hf } from "../../util/index";
import { h, ref, reactive ,onBeforeUpdate} from "vue";
import videoplay from "./videoplay.vue"
const props = defineProps({
    pup: { type: String },
    zfleix:{ type: String },
});
const showModal = ref(false)

let headBtn = ref([]);
const zdList = ref()
const databale = ref();
const videourl = ref()
const typeli = ref([])
const initeer = () => {
    databale.value.initDataExpose();
};
const hidebj = ref(false)
const emit = defineEmits(["callBack"]);
// 弹窗公用该列表
let dataJson = reactive([
    {
        title: "id",
        key: "id",
        width: 50,
    },

    {
        title: "产品名称",
        search: true, // 是否在搜索栏展示
        key: "title",
        width: 400,
    },
    {
        title: "类别",
        key: "sort",
        type: "select",
        search: true, // 是否在搜索栏展示
        width: 120,
        options: [],
        render(row) {
            try {
                return typeli.value.filter(a => a.value == row.sort)[0].label
            } catch (e) {
                return "--"
            }
        }
    },

    {
        title: "排序",
        width: 100,
        render(row) {
            row.databaseName = "xjyxproductManagement";
            return h(sort, {
                row,
                onCallBack: () => {
                    initeer();
                },
            });
        },
    },
    {
        title: "添加时间",
        key: "addTime",
        width: "140",
        type: "daterange",
    },
]);
let portUrl = "xjyx/xjyxproductManagement";
let qx = ref({
    DeletePermissionID: "xjyxproductManagementdel", //删除
    EditPermissionIdentifier: "xjyxproductManagementbj", // 编辑
    NewPermissionIdentifier: "xjyxproductManagementxz", // 新建
    ViewPermissionID: "xjyxproductManagementck", // 查看
})
if(props.pup==2){
 dataJson = [{
        title: "id",
        key: "id",
        width: 50,
    },

    {
        title: "产品名称",
        search: true, // 是否在搜索栏展示
        key: "title",
        width: 400,
    },
    {
        title: "类别",
        key: "sort",
        type: "select",
        search: true, // 是否在搜索栏展示
        width: 120,
        options: [],
        render(row) {
            try {
                return typeli.value.filter(a => a.value == row.sort)[0].label
            } catch (e) {
                return "--"
            }
        }
    },];
hidebj.value = true

qx.value = {
  DeletePermissionID: "23456", //删除
  EditPermissionIdentifier: "", // 编辑
  NewPermissionIdentifier: "23456", // 新建
  ViewPermissionID: "", // 查看
}
headBtn.value = [
  {
    name: "确认添加",
    jy: true,
    type: "info",
    clickFun: async (calld) => {
      if(calld.length<=0){
       window.$message.error('请在列表中勾选数据')
        return
      }
      const {data} =  await dxpost('xjyx/api/addCplibsd', { ids:calld.join(','), zfleix:props.zfleix})
     
      emit('callBack')
      },
  },
]
}




// onBeforeUpdate(()=>{
//     alert(66)
// })

const getcasetype = async () => {
    const { data }: any = await dxget("dxgjAdmin/getzd", { name: 'xjproductClassification' })

    dataJson[2].options = [
        {
            label: "全部",
            value: ""
        },
        ...data
    ]
    typeli.value = data
    // ishjwoer.value = true
}
getcasetype()

</script>
  
  
  